<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
if($_RQ['op']=='main'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$this->plugin_setting('basic',$postdata);
		exi('设置成功');
	}
	$formfileds =array(
		array('title'=>'联系人','type'=>'1','ismust'=>'0','value'=>''),
		array('title'=>'联系电话','type'=>'8','ismust'=>'0','value'=>''),
		array('title'=>'联系地址','type'=>'7','ismust'=>'0','value'=>''),
	);
	$baomingfileds =array(
		array('title'=>'货物名称','type'=>'1','ismust'=>'0','value'=>'货物名称'),
		array('title'=>'重量(吨)','type'=>'18','ismust'=>'0','value'=>'10'),
		array('title'=>'立方数','type'=>'2','ismust'=>'0','value'=>'30'),
	);
	$readtpls =array(
		array('picurl'=>'../addons/jy_wuliu/resource/images/readtpl01.jpg'),
		array('picurl'=>'../addons/jy_wuliu/resource/images/readtpl02.jpg'),
		array('picurl'=>'../addons/jy_wuliu/resource/images/readtpl03.jpg'),
		array('picurl'=>'../addons/jy_wuliu/resource/images/readtpl04.jpg'),
	);
	$footernav =array(
		array('title'=>'首页','icon'=>'icon-shouye','action'=>'jy_wuliu/index/'),
		array('title'=>'我的圈','icon'=>'icon-yonghujieru','action'=>'jy_wuliu/myquan/'),
		array('title'=>'发现专线','icon'=>'icon-map','action'=>'jy_wuliu/merch/'),
		array('title'=>'我的参与','icon'=>'icon-liebiaomoshi2','action'=>'jy_wuliu/feelog/'),
		array('title'=>'会员中心','icon'=>'icon-wo1','action'=>'jy_wuliu/myhome/'),
	);
	$huo_types =implode('|',$this->huo_types);
	$plugins =$this->plugins();
	$return['item']=$this->plugin_setting('basic');
	$return['item']['formfileds']=$return['item']['formfileds']?$return['item']['formfileds']:$formfileds;
	$return['item']['baomingfileds']=$return['item']['baomingfileds']?$return['item']['baomingfileds']:$baomingfileds;
	$return['item']['pingxuanfileds']=$return['item']['pingxuanfileds']?$return['item']['pingxuanfileds']:$pingxuanfileds;
	$return['item']['groupfileds']=$return['item']['groupfileds']?$return['item']['groupfileds']:$groupfileds;
	$return['item']['hudongfileds']=$return['item']['hudongfileds']?$return['item']['hudongfileds']:$hudongfileds;
	$return['item']['bgimgs']=$return['item']['bgimgs']?$return['item']['bgimgs']:$bgimgs;
	$return['item']['readtpls']=$return['item']['readtpls']?$return['item']['readtpls']:$readtpls;
	$return['item']['plugins']=$return['item']['plugins']?$return['item']['plugins']:$plugins[1]['list'];
	$return['item']['footernav']=$return['item']['footernav']?$return['item']['footernav']:$footernav;
	$return['item']['open_types']=$return['item']['open_types']?:';0;1;2;3;4;5;6;7;8;';
	$return['item']['huo_types']=$return['item']['huo_types']?$return['item']['huo_types']:$huo_types;
	$return['open_types']=$this->item_types;
	$htmls=array(
		'type'=>'edit',
		'desc'=>'参数设置',
		'tabs'=>$tabs,
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'基本信息',
				'list'=>array(
					array('type'=>'string','title'=>'网站名称','name'=>'title'),
					array('type'=>'image','title'=>'网站logo','name'=>'logo'),
					array('type'=>'image','title'=>'顶部背景图','name'=>'topbg','help'=>'建议尺寸宽480，高300'),
					array('type'=>'text','title'=>'货物类型','name'=>'huo_types','help'=>'温馨提示：请勿随意修改，否则影响已发消息分类情况。用|隔开，例如：器械设备|数码产品'),
					array('type'=>'switch','title'=>'开启地方圈?','name'=>'issns','help'=>'开启地方圈后，将根据不同行政区域展示圈主题信息！形成一个地方物流圈！'),
					array('type'=>'switch','title'=>'开启留言审核?','name'=>'msg_shenhe'),
					array('type'=>'switch','title'=>'开启帖子审核?','name'=>'item_shenhe'),
					
					array('type'=>'switch','title'=>'开启余额红包?','name'=>'isideal_money','help'=>'开启余额红包后，就关闭了微信红包，改用账户余额红包，红包资金进入奖金池，奖金池可以提现或转到余额'),
					array('type'=>'text','title'=>'地方圈默认描述','name'=>'quan_desc','help'=>'生活圈，分享时时动态，了解周边货运物流信息！这里有全国各地的货运物流供求信息......'),
					array('type'=>'string','title'=>'地方圈默认地址','name'=>'quan_district','help'=>'例如：物流圈村庄'),
					array('type'=>'string','title'=>'分享标题','name'=>'share_title'),
					array('type'=>'image','title'=>'分享图片','name'=>'share_image'),
					array('type'=>'string','title'=>'分享描述','name'=>'share_desc'),
				)
			),
			array(
				'title'=>'管理员设置',
				'list'=>array(
					array('type'=>'choose','title'=>'管理员UID','name'=>'adminuid','op'=>'get_member','choose_title'=>'选择会员','help'=>'便于接收平台高级消息！'),
					array('type'=>'choose','title'=>'客服人员ID','name'=>'kefuid','op'=>'get_member','choose_title'=>'选择会员'),
					array('type'=>'choose_many','name'=>'sysmid','title'=>'审核维护员ID','action'=>'core/member.get_member/many/','choose_title'=>'选择会员'),
				)
			),
			array(
				'title'=>'拼车设置',
				'list'=>array(
					array(
							'type'=>'array',
							'name'=>'formfileds',
							'add_tip'=>'参与人填写表单',
								'list'=>array(
									array('type'=>'string','name'=>'title','title'=>'标题'),
									array('type'=>'radio','name'=>'type','title'=>'类型','options'=>'types'),
									array('type'=>'radio','name'=>'ismust','title'=>'*必填?','options'=>'ismust'),
									
								),
								'details'=>array(
									array('type'=>'string','name'=>'title','title'=>'标题','help'=>''),
									array('type'=>'radio','name'=>'type','title'=>'类型','options'=>'types'),
									array('type'=>'switch','name'=>'ismust','title'=>'*必填?'),
								)
						),
					array(
							'type'=>'array',
							'name'=>'baomingfileds',
							'add_tip'=>'报名填写表单',
								'list'=>array(
									array('type'=>'string','name'=>'title','title'=>'标题'),
									array('type'=>'radio','name'=>'type','title'=>'类型','options'=>'types'),
									array('type'=>'radio','name'=>'ismust','title'=>'*必填?','options'=>'ismust'),
									
								),
								'details'=>array(
									array('type'=>'string','name'=>'title','title'=>'标题','help'=>''),
									array('type'=>'radio','name'=>'type','title'=>'类型','options'=>'types'),
									array('type'=>'switch','name'=>'ismust','title'=>'*必填?'),
								)
						),
			
				)
			),
			array(
				'title'=>'vip收费设置',
				'list'=>array(
					array('type'=>'string','title'=>'月费','name'=>'mfee'),
					array('type'=>'string','title'=>'月费原价','name'=>'mfee0'),
					array('type'=>'string','title'=>'季费','name'=>'jfee'),
					array('type'=>'string','title'=>'季费原价','name'=>'jfee0'),
					array('type'=>'string','title'=>'年费','name'=>'yfee'),
					array('type'=>'string','title'=>'年费原价','name'=>'yfee0'),
					array('type'=>'switch','title'=>'关闭限制会员才能发红包贴','name'=>'isfee_hongbao','help'=>'开启后，免费会员才能发布的红包主题帖子！'),
					array('type'=>'image','title'=>'充值会员页面背景图','name'=>'vipbg','help'=>'建议尺寸：高360px*宽640px'),
				)
			),
			array(
				'title'=>'申请车主/专线设置',
				'list'=>array(
					array('type'=>'switch','title'=>'车主申请需审核?','name'=>'ischezhu_shenhe'),
					array('type'=>'switch','title'=>'专线申请需审核?','name'=>'iszhuanxian_shenhe'),
					array('type'=>'radio','title'=>'车主申请条件?','name'=>'chezhu_becom','options'=>'chezhu_becom'),
					array('type'=>'string','title'=>'带来人数可申请车主','name'=>'chezhu_fromnum','show'=>array('chezhu_becom'=>1)),
					array('type'=>'radio','title'=>'专线申请条件?','name'=>'zhuanxian_becom','options'=>'zhuanxian_becom'),
					array('type'=>'string','title'=>'带来人数可申请专线','name'=>'zhuanxian_fromnum','show'=>array('zhuanxian_becom'=>1)),
				)
			),
			array(
				'title'=>'幻灯片',
					'list'=>array(
						array(
							'type'=>'array',
							'name'=>'hdps',
							'add_tip'=>'添加一个幻灯片',
								'list'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'幻灯片图片'),
									array('type'=>'string','name'=>'url','title'=>'幻灯片链接'),
									
								),
								'details'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'幻灯片图片','help'=>''),
									array('type'=>'string','name'=>'url','title'=>'幻灯片链接'),
									
								)
						)
					)
			),
			array(
				'title'=>'页面UI',
				'list'=>array(
					//array('type'=>'colorpicker','title'=>'项目顶部颜色','name'=>'r_color','help'=>'自定义系统颜色系，默认： red'),
					array('type'=>'image','title'=>'会员顶部图片','name'=>'h_img','help'=>'建议尺寸：高360px*宽640px'),
					array('type'=>'colorpicker','title'=>'会员顶部颜色','name'=>'h_color','help'=>'自定义系统颜色系，默认： red'),
					array('type'=>'image','title'=>'帖子内容顶部图片','name'=>'o_img','help'=>'建议尺寸：高360px*宽640px'),
					//array('type'=>'colorpicker','title'=>'帖子列表顶部颜色','name'=>'o_color','help'=>'自定义系统颜色系，默认： red'),
					array('type'=>'image','title'=>'发红包弹窗背景图','name'=>'o_hongbao','help'=>'发红包弹窗背景图，建议尺寸：高520px*宽360px'),
				)
			),
			array(
				'title'=>'底部导航',
					'list'=>array(
									array('type'=>'array','name'=>'footernav','add_tip'=>'添加一个底部导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),							
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
									)
								),
					)
			),
			array(
				'title'=>'小程序广告设置',
				'list'=>array(
					array('type'=>'string','title'=>'微信小程序帖子间广告ID','name'=>'wxapp_ad01','help'=>'例如：adunit-513cf0c735a3d48a'),
					array('type'=>'string','title'=>'支付宝小程序帖子间广告ID','name'=>'aliapp_ad01'),
					array('type'=>'string','title'=>'百度小程序帖子间广告ID','name'=>'baiduapp_ad01'),
					array('type'=>'string','title'=>'头条小程序帖子间广告ID','name'=>'ttapp_ad01'),
					array('type'=>'image','title'=>'自定义广告图片','name'=>'diy_adimg','help'=>'建议尺寸：宽580px,高:200px'),
					array('type'=>'link','from'=>'action','title'=>'自定义广告链接','name'=>'diy_adlink'),
					array('type'=>'string','title'=>'自定义广告标题','name'=>'diy_adtitle'),
					array('type'=>'switch','title'=>'开启联盟广告?','name'=>'is_lianad'),
					array('type'=>'text','title'=>'联盟广告JScode','name'=>'lian_adcode'),
				)
			),
		),
	);
	$return['types']=get_form_types();
	$return['ismust']=array('0'=>'非必填','1'=>'必填');
	$return['chezhu_becom']=array('0'=>'无条件','1'=>'带来用户数');
	$return['zhuanxian_becom']=array('0'=>'无条件','1'=>'带来用户数');
	$return['htmls']=$htmls;
	exi($return);
}

if($_RQ['op']=='get_member'){
	//会员列表
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$return['params']=$params=array();
	$params=array('uniacid'=>$_SESSION['uniacid']);
	$fields=array('username','nickname','mobile');
	if($_RQ['find']){
		$field=in_array($_RQ['field'],$fields)?$_RQ['field']:'nickname';
		$params[$field.' like']='%'.$_RQ['find'].'%';
		$return['params']['find']=$_RQ['find'];
		$return['params']['field']=$field;
	}
	$list=pdo_getslice('core_members',$params,array($pindex,$psize),$total,array('id','username','mobile','nickname','avatar'),'','id desc');
	if($list){
		foreach($list as &$item){
			$item['avatar'] = $item['avatar']?$item['avatar']:'../core/resource/images/nopic.jpg';
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'会员列表'),
		),
		'list'=>array('data'=>'list','del_one'=>false,'delall'=>false,'edit'=>false,'list'=>array(
		    array('name'=>'id','title'=>'会员id','type'=>'string'),
			array('name'=>'username','title'=>'会员账号','type'=>'string'),
			array('name'=>'mobile','title'=>'电话','type'=>'string'),
			array('name'=>'avatar','title'=>'头像','type'=>'image'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'id','title_field'=>'nickname','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'find','select_name'=>'field','select_title'=>'筛选','is_radio'=>true,'options'=>'fields'),
	);
	$return['fields']=array(
		'username'=>'会员账号',
		'nickname'=>'会员昵称',
		'mobile'=>'会员手机',
	);
	exi($return);
}